package com.hopital5.zhangyz.vo.response;

import com.hopital5.zhangyz.model.Label;
import com.hopital5.zhangyz.model.People;

import com.hopital5.zhangyz.vo.enums.PeopleSex;
import lombok.Builder;
import lombok.Data;

import javax.persistence.ManyToMany;
import java.util.List;
import java.util.stream.Collectors;

@Data
@Builder
public class PeopleVoResponse {
    private Long id;
    private String number;
    private String name;
    private PeopleSex peopleSex;
    private List<LabelVoResponse> labels;

    public static PeopleVoResponse build(People people) {
        PeopleVoResponse peopleVoResponse = PeopleVoResponse.builder()
                .id(people.getId())
                .number(people.getNumber())
                .name(people.getName())
                .peopleSex(people.getPeopleSex())
                .labels(people.getLabels().stream().map(LabelVoResponse::build).collect(Collectors.toList()))
                .build();
        return peopleVoResponse;
    }

}
